﻿#ifndef FFMPEGMANANGER_H
#define FFMPEGMANANGER_H
#pragma execution_character_set("utf-8")
#include <QObject>
#include <stdio.h>
#include <iostream>
#include <QTimer>
#include <QImage>
extern "C"
{
#include "libswscale/swscale.h"
#include "libavdevice/avdevice.h"
#include "libavcodec/avcodec.h"
#include "libavcodec/bsf.h"
#include "libavformat/avformat.h"
#include "libavutil/avutil.h"
#include "libavutil/imgutils.h"
#include "libavutil/log.h"
#include "libavutil/imgutils.h"
#include "libavutil/time.h"
#include <libswresample/swresample.h>

}
class ffmpegMananger: public QObject
{
    Q_OBJECT
public:
    explicit ffmpegMananger(QObject *parent = nullptr);
    ~ffmpegMananger();
    //获取RTSP URL
    void getRtspURL(QString strRtspURL);
    //设置输出位置
    void getOutURL(QString strRute);
    //ffmpeg拉流播放等相关操作
    int ffmepgInput();
    //打开解码器
    void openEncoder(int width, int height, AVCodecContext** enc_ctx);
    //设置输出上下文
    void setOutputCtx(AVCodecContext *encCtx, AVFormatContext **pTsFmtCtx,int &nVideoIdx_out);
    //写文件尾
    void writeTail();
    //设置解码的pts
    void setDecoderPts(int idx,int count,AVFrame *pFrame);
    //设置编码的pts
    void setEncoderPts(int nVideo_indx,int frame_index,int videoindex_out,AVPacket *newpkt);
signals:
    void Sig_GetOneFrame(QImage img);
private:
    QString m_qstrRtspURL;
    QString m_qstrOutPutFile;
    //输入
    AVFormatContext *m_pInFmtCtx;
    //文件操作Output
    AVFormatContext *m_pTsFmtCtx;
    bool m_ifRec;
};

#endif // FFMPEGMANANGER_H
